<!--
 * @Author: huangjing
 * @Date: 2022-04-02 10:33:24
 * @LastEditors: huangjing
 * @LastEditTime: 2022-04-07 16:47:08
 * @Description: file content
-->
<script lang="ts" setup>
import zhCn from "element-plus/lib/locale/lang/zh-cn";
import { useWebSocket } from "@/compositions/notice/useWebSocket"
const { initWebSocket, close } = useWebSocket()
const store = useStore()
const locale = ref(zhCn);
onMounted(() => {
  const route = useRoute()
  //非登录页,解决页面刷新之后websocket实例丢失
  if (route.fullPath.indexOf('/login') == -1) {
    if ((!store.state.notice.websocket) || Object.prototype.toString.call(store.state.notice.websocket.ws) != '[object WebSocket]') {
      initWebSocket()
    }
  }
  //刷新后清除通知中的查询数据
  store.commit("pointsMall/updateGoodsIds", [])
})
onBeforeUnmount(async () => {
  await  close()
})
</script>

<template>
  <el-config-provider :locale="locale">
    <router-view></router-view>
  </el-config-provider>
</template>

<style>
#app {
  /*min-width: 1000px;*/
  overflow: hidden;
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
}
</style>
